﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;

namespace Silverlight3dApp.Learning.Lesson04
{
    public class BouncingSprite : AutomatedSprite
    {
        public BouncingSprite(Texture2D texture, Vector2 position, Vector2 frameSize, int collisionOffset, Vector2 currentFrame, Vector2 sheetSize, Vector2 speed, SoundEffect collisionSound) : base(texture, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, collisionSound)
        {
        }

        public BouncingSprite(Texture2D texture, Vector2 position, Vector2 frameSize, int collisionOffset, Vector2 currentFrame, Vector2 sheetSize, Vector2 speed, SoundEffect collisionSound, int millisecondsPerFrame) : base(texture, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, collisionSound, millisecondsPerFrame)
        {
        }

        public override void Update(GameTime gameTime, Rectangle clientBounds)
        {
            base.Update(gameTime, clientBounds);
            _Position += Direction;
            if (_Position.X > (clientBounds.Width - _FrameSize.X) || _Position.X < 0)
            {
                _Speed.X *= -1;
            }
            if (_Position.Y > (clientBounds.Height - _FrameSize.Y) || _Position.Y < 0)
            {
                _Speed.Y *= -1;
            }
        }
    }
}